#
# @lc app=leetcode.cn id=141 lang=python3
#
# [141] 环形链表
#

# @lc code=start
# Definition for singly-linked list.
# class ListNode:
#     def __init__(self, x):
#         self.val = x
#         self.next = None

class Solution:
    def hasCycle(self, head: ListNode) -> bool:
        if head == None: return False
        fastP = head.next
        slowP = head
       
        if fastP == None: 
            return False
        elif fastP == slowP:
            return True
       
        while True:
            slowP = slowP.next
            fastP = fastP.next
            if fastP == None: 
                return False
            elif fastP == slowP:
                return True
            
            fastP = fastP.next
            if fastP == None: 
                return False
            elif fastP == slowP:
                return True
            
        
        
# @lc code=end

